#define _CRT_SECURE_NO_WARNINGS 1


#include <bits/stdc++.h>

using namespace std;
string n;
int main()
{
    cin >> n;
    while (n[0] == '0')
        n.erase(0, 1);
    int len = n.length() / 2;
    for (int i = 0, j = n.length() - 1; i <= len - 1; i++, j--)
    {
        if (n[i] > n[j])
        {
            int k = j - 1;
            while (k > 0 && n[k] == '0')
                n[k--] = '9';
            n[k]--;
            if (k == 0 && n[k] == '0')
            {
                n[j] = '9';
                n.erase(0, 1);
                break;
            }
        }
        n[j] = n[i];
    }
    cout << n << endl;
    return 0;
}